package offer;

public class Offer11 {

    public int minArray(int[] numbers) {
        int left=0;
        int right= numbers.length-1;
        while (left<right){
            int mid=left+(right-left)/2;
            if (numbers[mid]<numbers[right]){
                right=mid;

            }else if (numbers[mid]==numbers[right]){
                right--;
            }else {
                left=mid+1;
            }
        }
        return  numbers[left];

    }


}


/**
 * Author:Viper
 * Data:2021/3/11
 * description:
 */
 class problem11 {
    public int minArray(int[] numbers) {
        int len =numbers.length;
        if(len==0)
            return 0;
        int left=0,right=len-1;
        while(left<right){
            int mid = left+(right-left)/2;
            if(numbers[mid]<numbers[right])
                right=mid;
            else if(numbers[mid]==numbers[right])
                right--;
            else
                left=mid+1;
        }
        return numbers[left];
    }
}


